Skip to content

feat(errors): typed per-operation error hierarchy#540

Open
ayushiahjolia wants to merge 1 commit into
mainfrom
feat/typed-operation-error-hierarchy
Open

feat(errors): typed per-operation error hierarchy#540
ayushiahjolia wants to merge 1 commit into
mainfrom
feat/typed-operation-error-hierarchy

Conversation

@ayushiahjolia

@ayushiahjolia ayushiahjolia commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available: #120

Description of changes:

Replaces the single catch-all CallableRuntimeError with a typed, per-operation error hierarchy. A failed step, invoke, child context, or wait_for_condition now surfaces as a distinct, catchable exception type. It also lands the from_exception/throw_if_error changes those types require. The CallbackError rework and the nested-boundary regression test are intentionally deferred to follow-up PRs.

Breaking changes

  • Operation failures now raise the typed subclasses (StepError, InvokeError, ChildContextError, WaitForConditionError) instead of CallableRuntimeError (removed).
  • Catch on the exception class to identify the operation. The error_type attribute carries the original Python exception name (e.g. "ValueError"); the original message is on .message, and the original error is attached as cause (the live exception on first run, a reconstructed stand-in on replay). At the wire/checkpoint level, an escaping wrapper is recorded under its class-name discriminator (e.g. "StepError") one level up, while the operation's own FAIL checkpoint records the raw error type.
  • wait_for_condition check failures are now wrapped in WaitForConditionError rather than re-raised raw.
  • wait_for_callback/callback failures now surface as CallbackError (previously CallableRuntimeError); CallbackError remains in the termination tree until the follow-up.
  • An exhausted interrupted step fails immediately as StepError rather than round-tripping through a Lambda retry.

Testing

  • Updated/added unit tests across exceptions, lambda_service, state, concurrency, and the four operation handlers.
  • Added coverage for: registry + from_error_fields (including fallback), from_exception field preservation across a single operation boundary, raise_operation_error, wait_for_condition control-flow errors propagating unwrapped, and the execution result recording the StepError discriminator while the step's own FAIL checkpoint records the raw error type.
  • Added an integration test and an example; the example also verifies the caught error is identical across a wait/replay boundary.

Follow-ups

  • Move CallbackError under DurableOperationError with graded subclasses (CallbackExternalError, CallbackTimeoutError, CallbackSubmitterError) and drop CALLBACK_ERROR metadata.
  • Regression test for data surviving ≥2 nested run_in_child_context boundaries

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ayushiahjolia ayushiahjolia added this to the v2 milestone Jul 14, 2026
@ayushiahjolia
ayushiahjolia force-pushed the feat/typed-operation-error-hierarchy branch from e538dd6 to 5a8e07e Compare July 14, 2026 22:20
@ayushiahjolia
ayushiahjolia force-pushed the feat/typed-operation-error-hierarchy branch from 5a8e07e to a92d9cc Compare July 14, 2026 23:48
@ayushiahjolia ayushiahjolia removed this from the v2 milestone Jul 16, 2026
@ayushiahjolia
ayushiahjolia force-pushed the feat/typed-operation-error-hierarchy branch 5 times, most recently from 41eb1f2 to 51efedf Compare July 16, 2026 20:00
@ayushiahjolia
ayushiahjolia force-pushed the feat/typed-operation-error-hierarchy branch from 51efedf to f97cd67 Compare July 16, 2026 21:01
@ayushiahjolia
ayushiahjolia marked this pull request as ready for review July 16, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant